import {Debug_CheckUser} from '@/api/debug'
import * as auth from '../constants/AuthTypes'

export function CheckUserLogin(data){
    return (dispatch,getState) => {
        return Debug_CheckUser(data).then(res=>{
            console.log(data)
            let bool = res.list.some(item=>{
                if(item.username==data.username&item.password==data.password) return true
            })
            console.log(bool)
            if(bool) dispatch(auth.LoginSucc(bool))
            else dispatch(auth.LoginFail(bool))

            console.log(getState())
        }).catch(e=>{
            dispatch(auth.LoginFail(false))
        })
    }
}